package Model;

import Entity.AccountDetails;
import Manager.Manager;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author CONG
 */
public class AccountDetailsModel extends AbstractTableModel {
    private Manager manager;

    public AccountDetailsModel(Manager manager) {
        this.manager = manager;
    }
    
    @Override
    public int getRowCount() {
        return manager.getAccountDetailsManager().getSize();
    }

    @Override
    public int getColumnCount() {
        return 4;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        AccountDetails ad=manager.getAccountDetailsManager().getAccountDetails(rowIndex);
        switch(columnIndex){
            case 0:return ad.getRegisterNo();
            case 1:return ad.getAccountLoanCode();
            case 2:return ad.getBranchCode();
            case 3:return ad.getPeriod();
            default:return null;
        }
    }
    public void getAccountDetailsList(ArrayList<AccountDetails> ad){
    manager.getAccountDetailsManager().getAcccountDetailsList(ad);
    }
    public int getSize(){
        return manager.getAccountDetailsManager().getSize();
    }
    public AccountDetails getAccountDetails(int index){
        return manager.getAccountDetailsManager().getAccountDetails(index);
    }
    public void addAccountDetails(AccountDetails accde){
        manager.getAccountDetailsManager().addAccountDetails(accde);
        fireTableDataChanged();
    }
}
